/**
 *
 */
package com.angel.email.authenticator;

import javax.mail.Authenticator;
import javax.mail.PasswordAuthentication;

import com.angel.email.account.AccountInformation;

/**
 * @author William
 *
 */
public class EmailAuthenticator extends Authenticator {

	private String userName;
	private String userPassword;

	public EmailAuthenticator(AccountInformation accountInformation) {
		super();
		this.setUserName(accountInformation.getEmailAccount());
		this.setUserPassword(accountInformation.getPasswordAccount());
	}

	/**
	 * @return the userName
	 */
	public String getUserName() {
		return userName;
	}

	/**
	 * @param userName the userName to set
	 */
	public void setUserName(String userName) {
		this.userName = userName;
	}

	/**
	 * @return the userPassword
	 */
	public String getUserPassword() {
		return userPassword;
	}

	/**
	 * @param userPassword the userPassword to set
	 */
	public void setUserPassword(String userPassword) {
		this.userPassword = userPassword;
	}

	@Override
	public PasswordAuthentication getPasswordAuthentication() {
	    return new PasswordAuthentication(this.getUserName(), this.getUserPassword());
	  }
}
